package com.xiaoran.commonapi.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Rst {
    private Integer code;
    private String msg;
    private Object data;
    public Integer errorCode;
    public Integer successCode;
    public String errorMsg;
    public String successMsg;

    public Rst(Integer errorCode, Integer successCode, String successMsg, String errorMsg) {
        this.errorCode = errorCode;
        this.successCode = successCode;
        this.successMsg = successMsg;
        this.errorMsg = errorMsg;
    }

    public Rst(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Rst success(String msg, Object data) {
        return new Rst(successCode, msg, data);
    }

    public Rst success(Object data) {
        return new Rst(successCode, successMsg, data);
    }

    public Rst error(String msg) {
        return new Rst(errorCode, msg, null);
    }

    public Rst error() {
        return new Rst(errorCode, errorMsg, null);
    }

}
